package cn.g31010.sip.vo
{
	import com.adobe.cairngorm.vo.IValueObject;
	import com.adobe.serialization.json.JSON;

	public class Message implements IValueObject
	{
		public function Message()
		{
		}
		[Bindable]
		public var id:String;
		[Bindable]
		public var content:String;
		[Bindable]
		public var source:String;
		[Bindable]
		public var dest:String;
		
		public function toString():String{
			return JSON.encode(this);
		}
		
		public static function createFromJson(str:String):Message{
			if(str==null)
				return null;
			return create(JSON.decode(str));
		}
		
		public static function create(obj:Object):Message{
			if(obj==null)
				return null;
			var u:Message=new Message();
			if(obj.hasOwnProperty("id")){
				u.id=String(obj.id);
			}
			if(obj.hasOwnProperty("source")){
				u.source=String(obj.source);
			}
			if(obj.hasOwnProperty("dest")){
				u.dest=String(obj.dest);
			}
			if(obj.hasOwnProperty("content")){
				u.content=String(obj.content);
			}
			return u;
		}
	}
}